function change_1(id){
	var a = document.getElementById(id);
	a.src="icon/播放 (2).png"
	
}

function change_2(id){
	var a = document.getElementById(id);
	a.src="icon/播放.png"
	
}

function change_3(id){
	var a = document.getElementById(id);
	a.src="icon/下载 (3).png"
	
}

function change_4(id){
	var a = document.getElementById(id);
	a.src="icon/下载 (1).png"
	
}
function change_7(id){
	var a = document.getElementById(id);
	a.src="icon/删除-填充 (2).png"
	
}

function change_8(id){
	var a = document.getElementById(id);
	a.src="icon/删除-填充.png"
	
}

function change_5(id){
	var a = document.getElementById(id);
	a.children[0].style.display="";
	a.children[1].style.display="";
	a.children[2].style.display="";
	a.children[3].style.display="";
	//console.log(a.children[0])
	
}

function change_6(id){
	var a = document.getElementById(id);
	a.children[0].style.display="none";
	a.children[1].style.display="none";
	a.children[2].style.display="none";
	a.children[3].style.display="none";
	//console.log(a)
	/*data=id.substr(1,id.length-1);
	console.log(url)*/
	
}

function change_9(id){
	var a = document.getElementById(id);
	a.src="icon/收藏 (2).png"
	
}

function change_10(id){
	var a = document.getElementById(id);
	a.src="icon/收藏 (1).png"
}
	
function del(id)
{
	 var msg = "确认删除？";
	 if (confirm(msg)==true){
		var a=document.getElementById(id);
		a.parentElement.parentElement.remove();
		data=id.substr(1,id.length-1);
		$.getJSON(
			    'delServlet',
			    {"mid":data},
			    function(data){
			        console.log(data);
			        
			    }
			    )
	    return ;
		
	}else{
		return ;
	}
}

function play(id)
{
	var a=document.getElementById(id);
	data=id.substr(1,id.length-1);
	var b=document.getElementById("Pmp3");
	var b=document.getElementById("music");
	$.getJSON(
		    'GetSrcServlet',
		    {"mid":data},
		    function(result){
		        console.log(result);
		        b.src=result.src;
		        music.play();
		        console.log(b);
		        console.log(b.play);
		    }
		    )
	
	
}
function download(id){
	var a=document.getElementById(id);
	data=id.substr(1,id.length-1);
	
	window.location.href="DownloadServlet?mid="+data
	/*$.getJSON(
		    'DownloadServlet',
		    {"mid":data},
		    function(data){
		        console.log(data);
		    }
		    )
	alert("11");*/
}


function delAll()
{
	
	
		 var msg = "确认删除？";
		 if (confirm(msg)==true){
			 clear1();
			tr=document.getElementsByTagName("tr");
			console.log(tr[1].childNodes[1].firstChild.checked);
			var i=0;
			for(i=1;i<=tr.length;i++){
				if(tr[i].childNodes[1].firstChild.checked == true)
				{
					
					id=tr[i].childNodes[1].firstChild.id;
					data=id.substr(1,id.length-1);
					$.getJSON(
						    'delServlet',
						    {"mid":data},
						    function(data){
						        console.log(data);
						        
						    }
						    )
					tr[i].remove();
					i=i-1;
				}
			    return ;
			}
			
		}else{
			return ;
		}
		/*tr=document.getElementsByTagName("tr");
		var i=0;
		console.log(tr.length);
		for(i=1;i<tr.length;i++)
		{
			if(tr[i].childNodes[1].firstChild.checked == true)
			{
				
				console.log(tr[i]);
				id=tr[i].childNodes[i].firstChild.id;
				data=id.substr(1,id.length-1);
				console.log(data);
				var msg = "确认删除？";
				if (confirm(msg)==true){
				tr[i].remove();
				/*$.getJSON(
					    'FavoritesDelete',
					    {"mid":data},
					    function(data){
					        console.log(data);
					        
					    }
					    )
					    alert("成功");
				 }
				
				else{
					return;
				}
		
			}
		}*/
	
	
	
}

	
function downloadAll(){
	
	tr=document.getElementsByTagName("tr");
	console.log(tr[1].childNodes[1].firstChild.checked);
	var i=0;
	for(i=1;i<=tr.length;i++)
	if(tr[i].childNodes[1].firstChild.checked == true)
	{
		
		id=tr[i].childNodes[1].firstChild.id;
		data=id.substr(1,id.length-1);
		//alert("成功");
		console.log(data);
		window.location.href="DownloadServlet?mid="+data;
	}
    return ;
}


function save(id){
	var a=document.getElementById(id);
	data=id.substr(1,id.length-1);
	
	if(a.parentElement.children[3].onclick!=null){
		a.parentElement.children[3].onclick="";
		a.parentElement.children[3].onmouseout="";
		a.parentElement.children[3].onmousemove="";
		console.log(a.parentElement.children[3].onclick);
		$.getJSON(
				'FavoritesAdd',
				{"mid":data},
				function(data){
					console.log(data);        
				}
				)
	}
	
}

function saveAll(){
	111
	tr=document.getElementsByTagName("tr");
	console.log(tr[1].childNodes[1].firstChild.checked);
	var i=0;
	for(i=1;i<tr.length;i++)
	if(tr[i].childNodes[1].firstChild.checked == true)
	{
		
		id=tr[i].childNodes[1].firstChild.id;
		data=id.substr(1,id.length-1);
		//alert("成功");
		console.log(data);
		$.getJSON(
				'FavoritesAdd',
				{"mid":data},
				function(data){
					console.log(data);        
				}
				)
		console.log(tr[i].children[2].children[3].onclick);
		console.log(tr[i].children[2].children[3].src);
		tr[i].children[2].children[3].src="icon/收藏 (2).png";
		console.log(tr[i].children[2].children[3].src);
		tr[i].children[2].children[3].onclick="";
		tr[i].children[2].children[3].onmouseout="";
		tr[i].children[2].children[3].onmousemove="";
	}
}


function clear1(){
	console.log(111);   
	 var msg = "确认删除？";
	 tr=document.getElementsByTagName("tr");
	 if (confirm(msg)==true){
		 
		 for(i=1;i<tr.length;i++)
		{
			 	id=tr[i].childNodes[1].firstChild.id;
			 	data=id.substr(1,id.length-1);
				tr[i].remove();
				i=i-1;
				$.getJSON(
						'ClarServlet',
						{"mid":data},
						function(data){
							console.log(data);        
						}
					)
		}
		
	 }
}